<%@LANGUAGE="VBSCRIPT"%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>					
function DoDateTime(str, nNamedFormat, nLCID)				
	dim strRet								
	dim nOldLCID								
										
	strRet = str								
	If (nLCID > -1) Then							
		oldLCID = Session.LCID						
	End If									
										
	On Error Resume Next							
										
	If (nLCID > -1) Then							
		Session.LCID = nLCID						
	End If									
										
	If ((nLCID < 0) Or (Session.LCID = nLCID)) Then				
		strRet = FormatDateTime(str, nNamedFormat)			
	End If									
										
	If (nLCID > -1) Then							
		Session.LCID = oldLCID						
	End If									
										
	DoDateTime = strRet							
End Function									
</SCRIPT>
 
<!--#include file="functions.asp" -->

<%
' AND (STATUS = 'COMPLETED' OR STATUS='INVOICED' OR STATUS='OPEN' )
set CompCode = Server.CreateObject("ADODB.Recordset")
CompCode.ActiveConnection = cn
CompCode.Source = "SELECT *  FROM dbo.COMPCODE"
'CompCode.CursorType = 0
'CompCode.CursorLocation = 2
'CompCode.LockType = 3
CompCode.Open()
CompCode_numRows = 0
%>
<%
Dim EXIREG__tmpNum
EXIREG__tmpNum = "''"
if (Request.QueryString("LVONum")  <> "") then EXIREG__tmpNum = Request.QueryString("LVONum") 
%>
<%
set EXIREG = Server.CreateObject("ADODB.Recordset")
EXIREG.ActiveConnection = cn
EXIREG.Source = "SELECT LVONUM, REGNUM, INVNUM, CREATEDBY, REQUESTEDBY, UCCODE,STATUS, VENDORID, INVDATE, (DATEADD(DAY,3,INVDATE)) AS INVDUEDATE,ORDERDATE,DUEDATE, INVRECBY,DEPT, MP2CURRENCY, SYMBOL, COMPCODE, VATNUM, WHTNAME, VATRATE, SUBTOTAL,WHTRATE, WHTAMOUNT, VATPAIDTOVENDOR,  "_
&"(SELECT TOP 1 VENDOR.NAME  FROM VENDOR  WHERE VENDOR.VENDORID=EXILVOHEADER.VENDORID) AS VENDORNAME, "_
&"(SELECT EMPNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXILVOHEADER.INVRECBY) AS EMPNAME, INVVER, "_
&"(SELECT VERNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXILVOHEADER.INVVER) AS VERNAME,INVAPPR,"_
&"(SELECT APPRNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXILVOHEADER.INVAPPR) AS APPRNAME,INVVERDATE, INVAPPRDATE, ROUTEUSER,REFERENCEDOC, COMMENTS  FROM dbo.EXILVOHEADER  WHERE LVONUM='" + Replace(EXIREG__tmpNum, "'", "''") + "'"
'EXIREG.CursorType = 0
'EXIREG.CursorLocation = 2
'EXIREG.LockType = 3
EXIREG.Open()
EXIREG_numRows = 0
%>

<%
Dim LVODET__tmpNum
LVODET__tmpNum = "''"
if (Request.QueryString("LVONum") <> "") then LVODET__tmpNum = Request.QueryString("LVONum")
%>
<%
set LVODET = Server.CreateObject("ADODB.Recordset")
LVODET.ActiveConnection = cn
LVODET.Source = "SELECT SEQNUM,DESCRIPTION, QTYREQUESTED, UOP, UNITCOST, TOTAL, LINENUMBER, COSTCENTER, ACCTCODE, ACTCODE, TAXCODE, DEPTEMPCODE  FROM dbo.EXILVOREQ  WHERE LVONUM='" + Replace(LVODET__tmpNum, "'", "''") + "'  ORDER BY LINENUMBER"
'LVODET.CursorType = 0
'LVODET.CursorLocation = 2
'LVODET.LockType = 3
LVODET.Open()
LVODET_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
LVODET_numRows = LVODET_numRows + Repeat1__numRows
%>

<html>
<head>
<title>Invoice Detail</title>
<link rel="stylesheet" href="CAR_style.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" >
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
  <tr> 
    <td width="36%"> 
      <h4>LVO Invoice Detail</h4>
    </td>
    <td width="29%">&nbsp;</td>
    <td width="35%" align="right"><img src="images/Logo_premier2.jpg" width="164" height="40"> 
    </td>
  </tr>
  <tr> 
    <td colspan="3"><img src="images/hor_line.gif" width="100%" height="25"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="2" cellpadding="3">
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>LVO No.:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%" valign="middle"> <%=(EXIREG.Fields.Item("LVONUM").Value)%> 
    </td>
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>Status:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td><b><font color="#880000"><%=(EXIREG.Fields.Item("STATUS").Value)%></font></b></td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>Register No.:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%"> <%=(EXIREG.Fields.Item("REGNUM").Value)%> </td>
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>Invoice No.:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td> <%=(EXIREG.Fields.Item("INVNUM").Value)%> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>Received Date:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%"> <%=(EXIREG.Fields.Item("INVDATE").Value)%> </td>
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>Received By:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td> <%=(EXIREG.Fields.Item("INVRECBY").Value)%>&nbsp;&nbsp; <%=(EXIREG.Fields.Item("EMPNAME").Value)%> 
    </td>
  </tr>
  <tr> 
    <td width="15%"> 
      <div align="right"></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%">&nbsp; </td>
    <td width="15%"> 
      <div align="right"></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td>&nbsp; </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" height="22"> 
      <div align="right"><b>Order Date:&nbsp;</b></div>
    </td>
    <td width="2%" height="22">&nbsp;</td>
    <td width="30%" height="22"> <%= DoDateTime((EXIREG.Fields.Item("ORDERDATE").Value), 1, 2057) %> 
    </td>
    <td width="15%" bgcolor="#dedede" height="22"> 
      <div align="right"><b>Due Date:&nbsp;</b></div>
    </td>
    <td width="2%" height="22">&nbsp;</td>
    <td bgcolor="#FFFFFF" height="22"> <%= DoDateTime((EXIREG.Fields.Item("DUEDATE").Value), 1, 2057) %> 
    </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" height="21"> 
      <div align="right"><b>Vendor ID:&nbsp;</b></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td width="30%" height="21"> <%=(EXIREG.Fields.Item("VENDORID").Value)%> </td>
    <td width="15%" height="21"> 
      <div align="right"></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td bgcolor="#FFFFFF" height="21"> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" height="21"> 
      <div align="right"><b>Vendor Name:&nbsp;</b></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td height="21"> <%=(EXIREG.Fields.Item("VENDORNAME").Value)%> </td>
    <td bgcolor="#dedede" height="21"> 
      <div align="right"><b>Created By:&nbsp;</b></div>
    </td>
    <td height="21">&nbsp;</td>
    <td height="21"><%=(EXIREG.Fields.Item("CREATEDBY").Value)%> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" height="21"> 
      <div align="right"><b>Currency:&nbsp;</b></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td width="30%" height="21"> <%=(EXIREG.Fields.Item("MP2CURRENCY").Value)%> 
    </td>
    <td width="15%" bgcolor="#dedede" height="21"> 
      <div align="right"><b>Requested By:&nbsp;</b></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td height="21"><%=(EXIREG.Fields.Item("REQUESTEDBY").Value)%> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" height="21"> 
      <div align="right"><b>Sub Total:&nbsp;</b></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td width="30%" height="21"> <b><%=(EXIREG.Fields.Item("SYMBOL").Value)%>&nbsp;&nbsp; 
      <%=(FormatNumber((EXIREG.Fields.Item("SUBTOTAL").Value), -1, -2, -2, -1))%> 
      </b> </td>
    <td width="15%" bgcolor="#dedede" height="21"> 
      <div align="right"><b>Department:&nbsp;</b></div>
    </td>
    <td width="2%" height="21">&nbsp;</td>
    <td height="21"> <%=(EXIREG.Fields.Item("DEPT").Value)%> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>T0 Code:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%"> <%=EXIREG.Fields.Item("COMPCODE").Value %> </td>
    <td width="15%"> 
      <div align="right"></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td> 
      <% if (EXIREG.Fields.Item("VATPAIDTOVENDOR").Value="Y") then %>
      <img src="images/checkbw.jpg" width="18" height="17"> 
      <% else %>
      <img src="images/uncheck.jpg" width="14" height="14"> 
      <% end if %>
      VAT Paid To Vendor </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#FFFFFF"> 
      <div align="right"><b></b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%">&nbsp;</td>
    <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>WHT Name:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%"> <%=(EXIREG.Fields.Item("WHTNAME").Value)%> </td>
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>WHT Rate:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td> <%=(EXIREG.Fields.Item("WHTRATE").Value)%> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>VAT Rate:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td width="30%"> <%=(EXIREG.Fields.Item("VATRATE").Value)%> </td>
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>WHT Amount:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td> <%=(EXIREG.Fields.Item("WHTAMOUNT").Value)%> </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" align="right"><b>Verified By:&nbsp;</b></td>
    <td width="2%">&nbsp;</td>
    <td colspan="4"> <%=(EXIREG.Fields.Item("INVVER").Value)%> &nbsp; <%=(EXIREG.Fields.Item("VERNAME").Value)%> 
      &nbsp; 
      <% if (EXIREG.Fields.Item("INVVERDATE").Value<>"") then %>
      <img src="images/checkbw.jpg" width="18" height="17">&nbsp;Verified &nbsp; 
      <%= EXIREG.Fields.Item("INVVERDATE").Value %> 
      <% end if %>
    </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede" align="right"><b>Approved By:&nbsp;</b></td>
    <td width="2%">&nbsp;</td>
    <td colspan="4"> <%=(EXIREG.Fields.Item("INVAPPR").Value)%> &nbsp; <%=(EXIREG.Fields.Item("APPRNAME").Value)%> 
      &nbsp; 
      <% if (EXIREG.Fields.Item("INVAPPRDATE").Value<>"") then %>
      <img src="images/checkbw.jpg" width="18" height="17">&nbsp;Approved &nbsp; 
      <%= EXIREG.Fields.Item("INVAPPRDATE").Value %> 
      <% end if %>
    </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#dedede"> 
      <div align="right"><b>Comments:&nbsp;</b></div>
    </td>
    <td width="2%">&nbsp;</td>
    <td colspan="4"> 
      <pre><%=(EXIREG.Fields.Item("COMMENTS").Value)%></pre>
    </td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#FFFFFF" height="20">&nbsp;</td>
    <td width="2%" height="20">&nbsp;</td>
    <td width="30%" height="20">&nbsp;</td>
    <td width="15%" bgcolor="#FFFFFF" height="20">&nbsp;</td>
    <td width="2%" height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
  </tr>
  <% if(EXIREG.Fields.Item("STATUS").Value="INVOICED") or (EXIREG.Fields.Item("STATUS").Value="ROUTED") then %>
  <% end if %>
</table>

  
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#bbbbbb">
  <tr bgcolor="#efefef"> 
    <td width="4%" height="26"> 
      <div align="center"><font color="#000000"><b>No</b></font></div>
      </td>
      
    <td height="26"> 
      <div align="center"><font color="#000000"><b>Description </b></font></div>
      </td>
      
    <td width="5%" height="26"> 
      <div align="center"><font color="#000000"><b>Qty</b></font></div>
      </td>
      
    <td width="5%" height="26"> 
      <div align="center"><font color="#000000"><b>UoP</b></font></div>
      </td>
      
    <td width="8%" height="26"> 
      <div align="center"><font color="#000000"><b>Unit Cost</b></font></div>
      </td>
      
    <td width="8%" height="26"> 
      <div align="center"><font color="#000000"><b>Total</b></font></div>
      </td>
      
    <td height="26" width="10%"> 
      <div align="center"><b><b>Charge Code</b></b></div>
      </td>
      
    <td height="26" width="10%"> 
      <div align="center"><b><b>AFE</b></b></div>
      </td>
      
    <td height="26" width="8%"> 
      <div align="center"><b><b>Activity</b></b></div>
      </td>
      
    <td height="26" width="12%"> 
      <div align="center"><b>T3 Code</b></div>
      </td>
      
    <td height="26" width="5%"> 
      <div align="center"><b><font color="#FFFFFF"><font color="#000000"><b><b>Tax</b></b></font></font></b></div>
      </td>
    </tr>
    <% 
While ((Repeat1__numRows <> 0) AND (NOT LVODET.EOF)) 
%>
    <tr bgcolor="#FFFFFF" valign="top"> 
      <td width="4%"> 
        <div align="right"><%=(LVODET.Fields.Item("LINENUMBER").Value)%>.&nbsp;</div>
      </td>
      <td> 
        <%=(LVODET.Fields.Item("DESCRIPTION").Value)%></td>
      <td width="5%"> 
        <div align="right"><%=(LVODET.Fields.Item("QTYREQUESTED").Value)%></div>
      </td>
      <td width="5%"> 
        <div align="center"><%=(LVODET.Fields.Item("UOP").Value)%></div>
      </td>
      <td width="8%"> 
        <div align="right"><%= FormatNumber((LVODET.Fields.Item("UNITCOST").Value), -1, -2, -2, -1) %></div>
      </td>
      <td width="8%"> 
        <div align="right"><%= FormatNumber((LVODET.Fields.Item("TOTAL").Value), -1, -2, -2, -1) %></div>
      </td>
      <td width="10%"> 
        <div align="center"> 
          <%=(LVODET.Fields.Item("ACCTCODE").Value)%> </div>
      </td>
      <td width="10%"> 
        <div align="center"> 
          <%=(LVODET.Fields.Item("COSTCENTER").Value)%>
        </div>
      </td>
      <td width="8%"> 
        <div align="center"> 
          <%=(LVODET.Fields.Item("ACTCODE").Value)%>
        </div>
      </td>
      <td width="12%"> 
        <div align="center"> 
          <%=(LVODET.Fields.Item("DEPTEMPCODE").Value)%>
        </div>
      </td>
      <td width="5%"> 
        <div align="center"><%=(LVODET.Fields.Item("TAXCODE").Value)%></div>
      </td>
    </tr>
    <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  LVODET.MoveNext()
Wend
%>
    <tr bgcolor="#FFFFFF"> 
      <td width="4%"> 
        <div align="right"></div>
      </td>
      <td> 
        <div align="center"> </div>
      </td>
      <td width="5%">&nbsp;</td>
      <td width="5%">&nbsp;</td>
      <td width="8%"> 
        <div align="right"></div>
      </td>
      <td width="8%"> 
        <div align="right"></div>
      </td>
      <td width="10%">&nbsp;</td>
      <td width="10%">&nbsp;</td>
      <td width="8%">&nbsp;</td>
      <td width="12%">&nbsp;</td>
      <td width="5%">&nbsp;</td>
    </tr>
  </table>
</body>
</html>
<%
CompCode.Close()
%>
<%
EXIREG.Close()
%>
<%
LVODET.Close()
%>
